package cn.wikiflyer.beikang.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import cn.wikiflyer.beikang.R;

public class ViewWithRadio extends LinearLayout {
	private ImageView img_logo;
	private TextView tv_title;
	private TextView tv_info;
	private LinearLayout ll_parent;
	public ViewWithRadio(Context context) {
		this(context, null);
	}
	public ViewWithRadio(Context context, AttributeSet attrs) {
		super(context, attrs);
		addView(View.inflate(context, R.layout.bk_custom_view_with_radio, null));
		initView();
		loadParams(attrs);
	}
	private void initView(){
		img_logo = (ImageView) findViewById(R.id.imageView_logo);
		tv_title = (TextView) findViewById(R.id.textView_title);
		tv_info = (TextView) findViewById(R.id.textView_info);
		ll_parent = (LinearLayout) findViewById(R.id.ll_parent);
	}
	private void loadParams(AttributeSet attrs){
		TypedArray ta = this.getContext().obtainStyledAttributes(attrs, R.styleable.CustomRadion);
		String title = ta.getString(R.styleable.CustomRadion_paytitle);
		if (title != null) {
			tv_title.setText(title);
		}
		String info = ta.getString(R.styleable.CustomRadion_payinfo);
		if (info != null) {
			tv_info.setText(info);
		}
		Drawable logo = ta.getDrawable(R.styleable.CustomRadion_paylogo);
		if (logo != null) {
			img_logo.setImageDrawable(logo);
		}
		ta.recycle();
	}
	/**设置是否选中
	 */
	public void setChecked(boolean checked){
		if (checked) {
			ll_parent.setBackgroundResource(R.drawable.selected_bg);
		}else{
			ll_parent.setBackgroundColor(Color.WHITE);
		}
	}

	
	
}
